/**
 * Created by xiongxin on 2017/8/15.
 */


(function(app, angular) {

    app.controller('workAddCtrl', ['$scope', 'myFactory', '$ionicModal', function($scope, myFactory, $ionicModal) {


        initWorkAdd();
        function initWorkAdd() {

            $scope.applyTitle = '';   
            $scope.applyContent = '';

            // 工作申请类型接口
            myFactory.findJobTypes(function (result) {
                $scope.jobTypes = result.data;
                $scope.jobDefaultType = $scope.jobTypes[0].codeName;   //默认选中工作类型申请
            
            });

            // modal窗口弹出
            $ionicModal.fromTemplateUrl('work-add-modal.html', {
                scope: $scope,
                animation: 'slide-in-up'
            }).then(function(modal) {
                $scope.modal = modal;
            });
        }
        // 单选框触发事件
        $scope.workAddCli = function (item) {
            $scope.jobDefaultType = item.codeName;
            $scope.modalClose();
        };
        // 提交按钮
        $scope.workApplySum = function () {
            var option= {
                openUserid: '',
                title: $scope.applyTitle,
                content: $scope.applyContent,
                msgType: $scope.jobDefaultType,
                appUserId: ''
            };
            myFactory.findAppUser(function (result) {

            });
            
        };

        // myFactory.findAppUser(function (result) {
        //
        // });
            
        // 显示申请类型背景层    
        $scope.clickApplyType = function () {

            $scope.modal.show();


        };
        // 弹窗关闭icon点击事件
        $scope.modalClose =function () {
            $scope.modal.hide();
        };



    }]);
})(app, angular);
